#ifndef JOURNAL_H
#define JOURNAL_H

#include <coretypes.h>
#include <nettypes.h>

#include <QtCore/QHash>

namespace wfnet
{
class WfNet;

class Journal
{
public:
    Journal(WfNet* parent);

    int steps() const;
    core::TypeValue tokens(const net::nid& place) const;
    int executions(const net::nid& transition) const;

private:
    void incrementSteps();
    void transitionExecuted(const net::nid& transition);
    void finishJournal();

private:
    friend class WfNet;

    WfNet* m_parent;
    int m_steps;
    QHash<net::nid, core::TypeValue> m_tokens;
    QHash<net::nid, int> m_executions;
};

class BatchJournal
{
public:
    BatchJournal(WfNet* parent);

    uint runs() const;
    int steps(uint run) const;
    core::TypeValue tokens(uint run, const net::nid& place) const;
    int executions(uint run, const net::nid& transition) const;
    int executions(const net::nid &transition) const;

private:
    void beginNewRun();
    void incrementSteps();
    void transitionExecuted(const net::nid& transition);
    void finishJournal();

private:
    friend class NetRunnable;
    friend class WfNet;

    WfNet* m_parent;
    uint m_runs;
    QHash<uint, int> m_steps;
    QHash<QPair<uint, net::nid>, core::TypeValue> m_tokens;
    QHash<QPair<uint, net::nid>, int> m_executions;
};

} // namespace wfnet

#endif
